/*
 * Copyright 2009-2010 Original Author(s)
 * 
 * This file is part of Kommando
 * 
 * Kommando is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Kommando is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Kommando.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.kommando.alias.objectsource;

import javax.swing.Icon;

import org.kommando.core.catalog.AbstractCatalogObject;
import org.kommando.core.catalog.CatalogObject;
import org.kommando.core.util.Assert;

/**
 * @author Peter De Bruycker
 */
public class AliasObject extends AbstractCatalogObject {

    private CatalogObject object;
    private String alias;

    public AliasObject(CatalogObject object, String alias) {
        Assert.argumentNotNull("object", object);
        Assert.argumentNotEmpty("alias", alias);

        this.object = object;
        this.alias = alias;
    }

    @Override
    public String getId() {
        return "alias:" + alias + ":" + object.getId();
    }

    @Override
    public String getDescription() {
        return object.getDescription();
    }

    @Override
    public Icon getIcon() {
        // TODO decorate icon to indicate this is an aliased object

        return object.getIcon();
    }

    @Override
    public String getName() {
        return alias;
    }

    @Override
    public boolean hasExtension(Class<?> extensionType) {
        return object.hasExtension(extensionType);
    }

    @Override
    public <T> T getExtension(Class<T> extensionType) {
        return object.getExtension(extensionType);
    }

    @Override
    public String toString() {
        return "AliasObject[alias=" + alias + ", object=" + object + "]";
    }
}
